package com.cavy.platform.server.controller;

import com.cavy.platform.server.ResultInfo;
import com.cavy.platform.server.dto.PluginRepositorySettingCreateDto;
import com.cavy.platform.server.dto.PluginRepositorySettingDeleteDto;
import com.cavy.platform.server.dto.PluginRepositorySettingDto;
import com.cavy.platform.server.service.PluginRepositorySettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

/**
 * 插件仓库操作
 */
@RestController
@RequestMapping("/pluginRepositorySetting")
public class PluginRepositorySettingController {

    @Autowired
    private PluginRepositorySettingService service;

    //创建
    @PostMapping("/create")
    public ResultInfo create(@RequestBody @Valid PluginRepositorySettingCreateDto dto) throws IOException {
        service.create(dto);
        return ResultInfo.newSuccess();
    }

    //删除
    @PostMapping("/delete")
    public ResultInfo delete(@RequestBody @Valid PluginRepositorySettingDeleteDto dto) {
        service.delete(dto);
        return ResultInfo.newSuccess();
    }

    //列表
    @GetMapping("/list")
    public List<PluginRepositorySettingDto> list() {
        return service.list();
    }
}
